/*
*
* SPDX-License-Identifier: GPL-2.0
*
* Copyright (C) 2011-2018 ARM or its affiliates
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2.
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#if !defined(__OV5647_SENSOR_H__)
#define __OV5647_SENSOR_H__


/*-----------------------------------------------------------------------------
Initialization sequence - do not edit
-----------------------------------------------------------------------------*/

#include "sensor_init.h"
#define SMDATA 0
static acam_reg_t setting_1920_1080_2lane_30fps[] = {
	{0x0103, 0x01,0xff,1},		
	{0x3000, 0x00,0xff,1},
	{0x3001, 0x00,0xff,1},
	{0x3002, 0x00,0xff,1},
	{0x3016, 0x08,0xff,1},
	{0x3017, 0xE0,0xff,1},
	{0x3018, 0x44,0xff,1},
	{0x301C, 0xF8,0xff,1},
	{0x301D, 0xF0,0xff,1},
	{0x3034, 0x1A,0xff,1},
	{0x3035, 0x21,0xff,1},
	{0x3036, 0x62,0xff,1},
	{0x303C, 0x11,0xff,1},
	
	{0x3106, 0xF5,0xff,1},
#if SMDATA
	{0x3212, 0x00,0xff,1},
#else	
	{0x3212, 0xA0,0xff,1},
#endif
	{0x3500, 0x00,0xff,1},
#if SMDATA
	{0x3501, 0x46,0xff,1},
#else	
	{0x3501, 0x15,0xff,1},
#endif	
#if SMDATA
	{0x3502, 0x00,0xff,1},
#else	
	{0x3502, 0x20,0xff,1},
#endif	
	{0x3503, 0x03,0xff,1},
	{0x350A, 0x00,0xff,1},
#if SMDATA	
	{0x350B, 0x80,0xff,1},
#else	
	{0x350B, 0x10,0xff,1},
#endif	
	{0x3600, 0x37,0xff,1},
	{0x3612, 0x5B,0xff,1},
	{0x3618, 0x04,0xff,1},
	{0x3620, 0x64,0xff,1},
	{0x3621, 0xE0,0xff,1},
	{0x3630, 0x2E,0xff,1},
	{0x3632, 0xE2,0xff,1},
	{0x3633, 0x23,0xff,1},
	{0x3634, 0x44,0xff,1},
	{0x3636, 0x06,0xff,1},
	
	{0x3703, 0x5A,0xff,1},
	{0x3704, 0xA0,0xff,1},
	{0x3705, 0x1A,0xff,1},
	{0x3708, 0x64,0xff,1},
	{0x3709, 0x12,0xff,1},
	{0x370B, 0x60,0xff,1},
	{0x370C, 0x03,0xff,1},	
	{0x3715, 0x78,0xff,1},
	{0x3717, 0x01,0xff,1},
	{0x3731, 0x02,0xff,1},

	{0x3800, 0x01,0xff,1},
	{0x3801, 0x5C,0xff,1},
	{0x3802, 0x01,0xff,1},
	{0x3803, 0xB2,0xff,1},
	{0x3804, 0x08,0xff,1},
	{0x3805, 0xE3,0xff,1},
	{0x3806, 0x05,0xff,1},
	{0x3807, 0xF1,0xff,1},
	{0x3808, 0x07,0xff,1},
	{0x3809, 0x80,0xff,1},
	{0x380A, 0x04,0xff,1},
	{0x380B, 0x38,0xff,1},
	{0x380C, 0x09,0xff,1},
	{0x380D, 0x70,0xff,1},
	{0x380E, 0x04,0xff,1},
	{0x380F, 0x66,0xff,1},
	{0x3811, 0x04,0xff,1},
	{0x3813, 0x02,0xff,1},
	{0x3814, 0x11,0xff,1},
	{0x3815, 0x11,0xff,1},
	{0x3820, 0x00,0xff,1},
	{0x3821, 0x02,0xff,1},
	{0x3827, 0xEC,0xff,1},
	
	{0x3A08, 0x01,0xff,1},
	{0x3A09, 0x4B,0xff,1},
	{0x3A0A, 0x01,0xff,1},
	{0x3A0B, 0x13,0xff,1},
	{0x3A0D, 0x04,0xff,1},
	{0x3A0E, 0x03,0xff,1},
	{0x3A0F, 0x58,0xff,1},
	{0x3A10, 0x50,0xff,1},
	{0x3A11, 0x60,0xff,1},
	{0x3A18, 0x00,0xff,1},
	{0x3A19, 0xF8,0xff,1},	
	{0x3A1B, 0x58,0xff,1},	
	{0x3A1E, 0x50,0xff,1},
	{0x3A1F, 0x28,0xff,1},
	{0x3A50, 0x3b,0xff,1},
	{0x3A55, 0x06,0xff,1},
	{0x3A58, 0x28,0xff,1},
	{0x3A59, 0x9b,0xff,1},

	{0x3B07, 0x0C,0xff,1},

	{0x3C01, 0x80,0xff,1},
	{0x3C10, 0x59,0xff,1},
	{0x3C14, 0x63,0xff,1},
	{0x3C16, 0x0a,0xff,1},
	{0x3C18, 0x36,0xff,1},
	{0x3C1d, 0x22,0xff,1},
	
	{0x3F01, 0x0A,0xff,1},
	{0x3F05, 0x02,0xff,1},
	{0x3F06, 0x10,0xff,1},
	
	{0x4000, 0x09/*0x09*/,0xff,1},	
	{0x4001, 0x02,0xff,1},
	{0x4004, 0x04,0xff,1},
#if SMDATA
	{0x4005, 0x18,0xff,1},
#else	
	{0x4005, 0x1c,0xff,1},
#endif
#if SMDATA
#endif

	{0x4800, 0x34,0xff,1},
	{0x4837, 0x19,0xff,1},
	
	
	{0x5000, 0x06,0xff,1},
	{0x5002, 0x40,0xff,1},
	{0x5003, 0x08,0xff,1},
	{0x503D, 0x00,0xff,1},
	
	{0x5A00, 0x08,0xff,1},
	{0x5A04, 0x00,0xff,1},
	{0x5A43, 0x00,0xff,1},
	{0x5A45, 0x00,0xff,1},

	{ 0x0000, 0x0000, 0x0000, 0x0000 },
};

static acam_reg_t setting_2592_1944_2lane_15fps[] = {
#if 1
	{0x3035,0x21,0xff,1},
	{0x3036,0x46,0xff,1},
	{0x303c,0x11,0xff,1},
	{0x3821,0x07,0xff,1},
	{0x3820,0x41,0xff,1},
	{0x3612,0x59,0xff,1},
	{0x3618,0x00,0xff,1},
	{0x380c,0x07,0xff,1},
	{0x380d,0x68,0xff,1},
	{0x380e,0x03,0xff,1},
	{0x380f,0xd8,0xff,1},
	{0x3814,0x31,0xff,1},
	{0x3815,0x31,0xff,1},
	{0x3708,0x64,0xff,1},
	{0x3709,0x52,0xff,1},
	{0x3808,0x05,0xff,1},
	{0x3809,0x00,0xff,1},
	{0x380a,0x03,0xff,1},
	{0x380b,0xc0,0xff,1},
	{0x3800,0x00,0xff,1},
	{0x3801,0x18,0xff,1},
	{0x3802,0x00,0xff,1},
	{0x3803,0x0e,0xff,1},
	{0x3804,0x0a,0xff,1},
	{0x3805,0x27,0xff,1},
	{0x3806,0x07,0xff,1},
	{0x3807,0x95,0xff,1},
	{0x3a08,0x01,0xff,1},
	{0x3a09,0x27,0xff,1},
	{0x3a0a,0x00,0xff,1},
	{0x3a0b,0xf6,0xff,1},
	{0x3a0d,0x04,0xff,1},
	{0x3a0e,0x03,0xff,1},
	{0x4004,0x02,0xff,1},
	{0x4837,0x7d,0xff,1},
	
	{0x3035,0x71,0xff,1},
	{0x3036,0x46,0xff,1},
#else

	{0x0103, 0x01,0xff,1},
      {0x3034, 0x1A,0xff,1},
      {0x3035, 0x21,0xff,1},
      {0x3036, 0x34,0xff,1},
      {0x303C, 0x11,0xff,1},
      {0x3106, 0xF5,0xff,1},
      {0x3827, 0xEC,0xff,1},
      {0x370C, 0x03,0xff,1},
      {0x3612, 0x5B,0xff,1},
      {0x3618, 0x04,0xff,1},
      {0x5000, 0x06,0xff,1},
      {0x5002, 0x40,0xff,1},
      {0x5003, 0x08,0xff,1},
      {0x5A00, 0x08,0xff,1},
      {0x3000, 0x00,0xff,1},
      {0x3001, 0x00,0xff,1},
      {0x3002, 0x00,0xff,1},
      {0x3016, 0x08,0xff,1},
      {0x3017, 0xE0,0xff,1},
      {0x3018, 0x44,0xff,1},
      {0x301C, 0xF8,0xff,1},
      {0x301D, 0xF0,0xff,1},
      {0x3A18, 0x00,0xff,1},
      {0x3A19, 0xF8,0xff,1},
      {0x3C01, 0x80,0xff,1},
      {0x3B07, 0x0C,0xff,1},
      {0x380C, 0x1F,0xff,1},
      {0x380D, 0x1B,0xff,1},
      {0x3814, 0x11,0xff,1},
      {0x3815, 0x11,0xff,1},
      {0x3708, 0x64,0xff,1},
      {0x3709, 0x12,0xff,1},
      {0x3808, 0x0A,0xff,1},
      {0x3809, 0x20,0xff,1},
      {0x380A, 0x07,0xff,1},
      {0x380B, 0x98,0xff,1},
      {0x3800, 0x00,0xff,1},
      {0x3801, 0x00,0xff,1},
      {0x3802, 0x00,0xff,1},
      {0x3803, 0x00,0xff,1},
      {0x3804, 0x0A,0xff,1},
      {0x3805, 0x3F,0xff,1},
      {0x3806, 0x07,0xff,1},
      {0x3807, 0xA3,0xff,1},
      {0x3811, 0x10,0xff,1},
      {0x3813, 0x06,0xff,1},
      {0x3630, 0x2E,0xff,1},
      {0x3632, 0xE2,0xff,1},
      {0x3633, 0x23,0xff,1},
      {0x3634, 0x44,0xff,1},
      {0x3636, 0x06,0xff,1},
      {0x3620, 0x64,0xff,1},
      {0x3621, 0xE0,0xff,1},
      {0x3600, 0x37,0xff,1},
      {0x3704, 0xA0,0xff,1},
      {0x3703, 0x5A,0xff,1},
      {0x3715, 0x78,0xff,1},
      {0x3717, 0x01,0xff,1},
      {0x3731, 0x02,0xff,1},
      {0x370B, 0x60,0xff,1},
      {0x3705, 0x1A,0xff,1},
      {0x3F05, 0x02,0xff,1},
      {0x3F06, 0x10,0xff,1},
      {0x3F01, 0x0A,0xff,1},
      {0x3A08, 0x01,0xff,1},
      {0x3A09, 0x28,0xff,1},
      {0x3A0A, 0x00,0xff,1},
      {0x3A0B, 0xF6,0xff,1},
      {0x3A0D, 0x08,0xff,1},
      {0x3A0E, 0x06,0xff,1},
      {0x3A0F, 0x58,0xff,1},
      {0x3A10, 0x50,0xff,1},
      {0x3A1B, 0x58,0xff,1},
      {0x3A1E, 0x50,0xff,1},
      {0x3A11, 0x60,0xff,1},
      {0x3A1F, 0x28,0xff,1},
      {0x4001, 0x02,0xff,1},
      {0x4004, 0x04,0xff,1},
      {0x4000, 0x09,0xff,1},
      {0x4837, 0x16,0xff,1},
      {0x4800, 0x24,0xff,1},
      {0x3503, 0x03,0xff,1},
      {0x3820, 0x00,0xff,1},
      {0x3821, 0x02,0xff,1},
      {0x380E, 0x15,0xff,1},
      {0x380F, 0x56,0xff,1},
      {0x350A, 0x00,0xff,1},
      {0x350B, 0x10,0xff,1},
      {0x3500, 0x00,0xff,1},
      {0x3501, 0x03,0xff,1},
      {0x3502, 0x60,0xff,1},
      {0x3212, 0xA0,0xff,1},
#endif      
	{ 0x0000, 0x0000, 0x0000, 0x0000 },
};

static acam_reg_t setting_640_480_2lane_60fps[] = {
      {0x0103, 0x01,0xff,1},
      {0x3036, 0x46,0xff,1},
      {0x303C, 0x11,0xff,1},
      {0x370C, 0x03,0xff,1},
      {0x3612, 0x59,0xff,1},
      {0x3618, 0x00,0xff,1},
      {0x5000, 0x06,0xff,1},
      {0x5003, 0x08,0xff,1},
      {0x5A00, 0x08,0xff,1},
      {0x301D, 0xF0,0xff,1},
      {0x3A18, 0x00,0xff,1},
      {0x3A19, 0xF8,0xff,1},
      {0x3C01, 0x80,0xff,1},
      {0x3B07, 0x0C,0xff,1},
      {0x380C, 0x07,0xff,1},
      {0x380D, 0x3C,0xff,1},
      {0x3814, 0x71,0xff,1},
      {0x3815, 0x71,0xff,1},
      {0x3708, 0x64,0xff,1},
      {0x3709, 0x52,0xff,1},
      {0x3808, 0x02,0xff,1},
      {0x3809, 0x80,0xff,1},
      {0x380A, 0x01,0xff,1},
      {0x380B, 0xE0,0xff,1},
      {0x3800, 0x00,0xff,1},
      {0x3801, 0x10,0xff,1},
      {0x3802, 0x00,0xff,1},
      {0x3803, 0x00,0xff,1},
      {0x3804, 0x0A,0xff,1},
      {0x3805, 0x2F,0xff,1},
      {0x3806, 0x07,0xff,1},
      {0x3807, 0x9F,0xff,1},
      {0x3630, 0x2E,0xff,1},
      {0x3632, 0xE2,0xff,1},
      {0x3633, 0x23,0xff,1},
      {0x3634, 0x44,0xff,1},
      {0x3620, 0x64,0xff,1},
      {0x3621, 0xE0,0xff,1},
      {0x3600, 0x37,0xff,1},
      {0x3704, 0xA0,0xff,1},
      {0x3703, 0x5A,0xff,1},
      {0x3715, 0x78,0xff,1},
      {0x3717, 0x01,0xff,1},
      {0x3731, 0x02,0xff,1},
      {0x370B, 0x60,0xff,1},
      {0x3705, 0x1A,0xff,1},
      {0x3F05, 0x02,0xff,1},
      {0x3F06, 0x10,0xff,1},
      {0x3F01, 0x0A,0xff,1},
      {0x3A08, 0x01,0xff,1},
      {0x3A09, 0x2E,0xff,1},
      {0x3A0A, 0x00,0xff,1},
      {0x3A0B, 0xFB,0xff,1},
      {0x3A0D, 0x02,0xff,1},
      {0x3A0E, 0x01,0xff,1},
      {0x3A0F, 0x58,0xff,1},
      {0x3A10, 0x50,0xff,1},
      {0x3A1B, 0x58,0xff,1},
      {0x3A1E, 0x50,0xff,1},
      {0x3A11, 0x60,0xff,1},
      {0x3A1F, 0x28,0xff,1},
      {0x4001, 0x02,0xff,1},
      {0x4004, 0x02,0xff,1},
      {0x4000, 0x09,0xff,1},
      {0x3000, 0x00,0xff,1},
      {0x3001, 0x00,0xff,1},
      {0x3002, 0x00,0xff,1},
      {0x3017, 0xE0,0xff,1},
      {0x3636, 0x06,0xff,1},
      {0x3016, 0x08,0xff,1},
      {0x3827, 0xEC,0xff,1},
      {0x3018, 0x44,0xff,1},
      {0x3035, 0x21,0xff,1},
      {0x3106, 0xF5,0xff,1},
      {0x3034, 0x1A,0xff,1},
      {0x301C, 0xF8,0xff,1},
      {0x4800, 0x34,0xff,1},
      {0x3503, 0x03,0xff,1},
      {0x3820, 0x41,0xff,1},
      {0x3821, 0x03,0xff,1},
      {0x380E, 0x02,0xff,1},
      {0x380F, 0xEC,0xff,1},
      {0x350A, 0x00,0xff,1},
      {0x350B, 0x10,0xff,1},
      {0x3500, 0x00,0xff,1},
      {0x3501, 0x13,0xff,1},
      {0x3502, 0xB0,0xff,1},
      {0x3212, 0xA0,0xff,1},
	{ 0x0000, 0x0000, 0x0000, 0x0000 },
};

static acam_reg_t setting_1296_730_2lane_30fps[] = {
	{0x0103, 0x01,0xff,1},
		  {0x3034, 0x1A,0xff,1},
		  {0x3035, 0x21,0xff,1},
		  {0x3036, 0x62,0xff,1},
		  {0x303C, 0x11,0xff,1},
		  {0x3106, 0xF5,0xff,1},
		  {0x3827, 0xEC,0xff,1},
		  {0x370C, 0x03,0xff,1},
		  {0x3612, 0x59,0xff,1},
		  {0x3618, 0x00,0xff,1},
		  {0x5000, 0x06,0xff,1},
		  {0x5002, 0x40,0xff,1},
		  {0x5003, 0x08,0xff,1},
		  {0x5A00, 0x08,0xff,1},
		  {0x3000, 0x00,0xff,1},
		  {0x3001, 0x00,0xff,1},
		  {0x3002, 0x00,0xff,1},
		  {0x3016, 0x08,0xff,1},
		  {0x3017, 0xE0,0xff,1},
		  {0x3018, 0x44,0xff,1},
		  {0x301C, 0xF8,0xff,1},
		  {0x301D, 0xF0,0xff,1},
		  {0x3A18, 0x00,0xff,1},
		  {0x3A19, 0xF8,0xff,1},
		  {0x3C01, 0x80,0xff,1},
		  {0x3B07, 0x0C,0xff,1},
		  {0x3800, 0x00,0xff,1},
		  {0x3801, 0x00,0xff,1},
		  //NB This value IS INCORRECT, but has been incorrect for long enough
		  //that changing it will cause complaints due to changing FOV.
		  //(It should be (0x3802, 00,0xff,1}, (0x3803, F0) to give a symmetric crop).
		  //Correct the value so debug_mode isn't set, but the result is the same.
		  {0x3802, 0x00,0xff,1},
		  {0x3803, 0x00,0xff,1},
		  {0x3804, 0x0A,0xff,1},
		  {0x3805, 0x3F,0xff,1},
		  //For a symmetric crop, use (0x3806, 0x06,0xff,1}, (0x3807,0xB3)
		  {0x3806, 0x05,0xff,1},
		  {0x3807, 0xbf,0xff,1},
		  {0x3808, 0x05,0xff,1},
		  {0x3809, 0x10,0xff,1},
		  {0x380A, 0x02,0xff,1},
		  {0x380B, 0xDA,0xff,1},
		  {0x380C, 0x07,0xff,1},
		  {0x380D, 0x68,0xff,1},
		  {0x3811, 0x10,0xff,1},
		  {0x3813, 0x06,0xff,1},
		  {0x3814, 0x31,0xff,1},
		  {0x3815, 0x31,0xff,1},
		  {0x3630, 0x2E,0xff,1},
		  {0x3632, 0xE2,0xff,1},
		  {0x3633, 0x23,0xff,1},
		  {0x3634, 0x44,0xff,1},
		  {0x3636, 0x06,0xff,1},
		  {0x3620, 0x64,0xff,1},
		  {0x3621, 0xE0,0xff,1},
		  {0x3600, 0x37,0xff,1},
		  {0x3704, 0xA0,0xff,1},
		  {0x3703, 0x5A,0xff,1},
		  {0x3715, 0x78,0xff,1},
		  {0x3717, 0x01,0xff,1},
		  {0x3731, 0x02,0xff,1},
		  {0x370B, 0x60,0xff,1},
		  {0x3705, 0x1A,0xff,1},
		  {0x3F05, 0x02,0xff,1},
		  {0x3F06, 0x10,0xff,1},
		  {0x3F01, 0x0A,0xff,1},
		  {0x3A08, 0x01,0xff,1},
		  {0x3A09, 0x28,0xff,1},
		  {0x3A0A, 0x00,0xff,1},
		  {0x3A0B, 0xF6,0xff,1},
		  {0x3A0D, 0x08,0xff,1},
		  {0x3A0E, 0x06,0xff,1},
		  {0x3A0F, 0x58,0xff,1},
		  {0x3A10, 0x50,0xff,1},
		  {0x3A1B, 0x58,0xff,1},
		  {0x3A1E, 0x50,0xff,1},
		  {0x3A11, 0x60,0xff,1},
		  {0x3A1F, 0x28,0xff,1},
		  {0x4001, 0x02,0xff,1},
		  {0x4004, 0x04,0xff,1},
		  {0x4000, 0x09,0xff,1},
		  {0x4837, 0x16,0xff,1},
		  {0x4800, 0x24,0xff,1},
		  {0x3503, 0x03,0xff,1},
		  {0x3820, 0x41,0xff,1},
		  {0x3821, 0x03,0xff,1},
		  {0x380E, 0x05,0xff,1},
		  {0x380F, 0x9B,0xff,1},
		  {0x350A, 0x00,0xff,1},
		  {0x350B, 0x10,0xff,1},
		  {0x3500, 0x00,0xff,1},
		  {0x3501, 0x1A,0xff,1},
		  {0x3502, 0xF0,0xff,1},
		  {0x3212, 0xA0,0xff,1},

	{ 0x0000, 0x0000, 0x0000, 0x0000 },
};

static acam_reg_t settings_context_ov5647[] = {
    //stop sequence - address is 0x0000
    { 0x0000, 0x0000, 0x0000, 0x0000 }
};

static const acam_reg_t *seq_table[] = {
    setting_1920_1080_2lane_30fps,
    setting_2592_1944_2lane_15fps,
    setting_640_480_2lane_60fps,
    setting_1296_730_2lane_30fps,
};

static const acam_reg_t *isp_seq_table[] = {
    settings_context_ov5647,
};


#define SENSOR__OV5647_SEQUENCE_DEFAULT seq_table
#define SENSOR__OV5647_ISP_SEQUENCE_DEFAULT seq_table


#define SENSOR_OV5647_SEQUENCE_DEFAULT_INIT    0
#define SENSOR_OV5647_SEQUENCE_DEFAULT_PREVIEW    1
#define SENSOR_OV5647_SEQUENCE_SECOND_PREVIEW    2
#define SENSOR_OV5647_SEQUENCE_THIRD_PREVIEW    3
#define SENSOR_OV5647_SEQUENCE_S2_PREVIEW    4
#define SENSOR_OV5647_SEQUENCE_S4_PREVIEW    5

#define SENSOR_OV5647_ISP_CONTEXT_SEQ   0


#endif /* __OV08A10_SENSOR_H__ */
